/*
 * @Author: your name
 * @Date: 2020-09-25 09:58:54
 * @LastEditTime: 2020-09-25 14:17:05
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \antd-vue-pro\src\mock\services\table.js
 */
import Mock from 'mockjs2'
import {
  builder,
  getQueryParameters
} from '../util'

const depart = ["熔炼车间", "精炼车间", "炼渣车间"];
const craft = ["顶吹炉", "炼前处理", "电炉车间", '火法精炼', '20t真空炉', '锡电解', '隔膜电解', '1#烟化炉', '2#烟化炉'];
const energy = ["电", "烟煤", "无烟煤", '清水', '煤气'];
const unit = ["kgce/t", "kwh/t", "t/t", 'm3'];

const tablelist = (options) => {
  const queryParameters = getQueryParameters(options)
  console.log('queryParameters', queryParameters)
  if (queryParameters && !queryParameters.count) {
    queryParameters.count = 5
  }

  //   const data = []
  //   for (let i = 0; i < queryParameters.count; i++) {
  //     const tmpKey = i + 1
  //     const num = parseInt(Math.random() * (4 + 1), 10)
  //     data.push({
  //       id: tmpKey,
  //       depart: depart[num],
  //       craft: craft[num],
  //       energy: energy[num],
  //       unit: unit[num],
  //       num: Mock.mock('@integer(1, 999)'),
  //       updatedAt: Mock.mock('@datetime'),

  //       activeUser: Math.ceil(Math.random() * 100000) + 100000,
  //       newUser: Math.ceil(Math.random() * 1000) + 1000,
  //     //   cover: parseInt(i / 4, 10) % 2 === 0 ? covers[i % 4] : covers[3 - (i % 4)]
  //     })
  //   }

  const data = [{
    "id": 1,
    "depart": "精炼车间",
    "craft": "火法精炼",
    "energy": "清水",
    "unit": "m3",
    "num": 798,
    "updatedAt": "2005-09-09 23:39:07",
    "activeUser": 185652,
    "newUser": 1010
  },{
    "id": 3,
    "depart": "精炼车间",
    "craft": "火法精炼",
    "energy": "电",
    "unit": "kwh/t",
    "num": 862,
    "updatedAt": "2013-05-03 17:42:14",
    "activeUser": 181863,
    "newUser": 1036
  }, {
    "id": 2,
    "depart": "熔炼车间",
    "craft": "20t真空炉",
    "energy": "煤气",
    "unit": "kgce/t",
    "num": 261,
    "updatedAt": "2012-12-02 10:48:51",
    "activeUser": 101789,
    "newUser": 1490
  },  {
    "id": 5,
    "depart": "熔炼车间",
    "craft": "20t真空炉",
    "energy": "电",
    "unit": "kwh/t",
    "num": 936,
    "updatedAt": "1993-07-18 13:36:07",
    "activeUser": 100048,
    "newUser": 1869
  },{
    "id": 4,
    "depart": "熔炼车间",
    "craft": "顶吹炉",
    "energy": "烟煤",
    "unit": "kgce/t",
    "num": 693,
    "updatedAt": "1972-12-29 19:31:45",
    "activeUser": 141648,
    "newUser": 1395
  },{
    "id": 6,
    "depart": "熔炼车间",
    "craft": "顶吹炉",
    "energy": "天燃气",
    "unit": "m3",
    "num": 693,
    "updatedAt": "1972-12-29 19:31:45",
    "activeUser": 141648,
    "newUser": 1395
  },{
    "id": 7,
    "depart": "熔炼车间",
    "craft": "顶吹炉",
    "energy": "无烟煤",
    "unit": "kgce/t",
    "num": 693,
    "updatedAt": "1972-12-29 19:31:45",
    "activeUser": 141648,
    "newUser": 1395
  }]
  return builder(data)

}

Mock.mock(/\/table\/list/, 'get', tablelist)